package com.shop.service.impl;

import com.github.pagehelper.PageInfo;
import com.shop.vo.ProductAggregationVO;
import com.shop.entity.ProductSku;
import com.shop.mapper.ProductSkuMapper;
import com.shop.service.ProductSkuService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("productSkuService")
@RequiredArgsConstructor
@Transactional(rollbackFor = RuntimeException.class,
        propagation = Propagation.REQUIRED)
public class ProductSkuServiceImpl implements ProductSkuService {
    private final ProductSkuMapper productSkuMapper;
    @Override
    public PageInfo<ProductSku> listProductSku(int pageNum, int pageSize) {
        return new PageInfo<>(productSkuMapper.listProductSku(pageNum, pageSize));
    }

    @Override
    public PageInfo<ProductSku> listWithProductSku(int pageNum, int pageSize) {
        return new PageInfo<>(productSkuMapper.listWithProductSku(pageNum, pageSize));
    }

    @Override
    public ProductSku listProductSkuByProductId(Integer productId) {
        return productSkuMapper.listProductSkuByProductId(productId);
    }

    @Override
    public void addProductSku(ProductSku productSku) {
        productSkuMapper.addProductSku(productSku);
    }

    @Override
    public void deleteProductSku(Integer id) {
        productSkuMapper.deleteProductSku(id);
    }

    @Override
    public void updateProductSku(Integer id, String skuCode, double price, int stock) {
        productSkuMapper.updateProductSku(id, skuCode, price, stock);
    }

    @Override
    public int getTotal() {
        return productSkuMapper.getTotal();
    }
}
